
<div class="templatemo-content-wrapper">
	<div class="templatemo-content">
		<ul class="nav nav-tabs mytabs">
		  <li class="active"><a href="#">编辑送货员</a></li>
		  <li ><a href="<?=site_url()?>/deliveryman/index">送货员列表</a></li>
		  <li  role="presentation"><a href="<?=site_url()?>/deliveryman/add"><i class="fa fa-plus"></i> 添加送货员</a></li>
		</ul>
		<div class="row">
			<div class="col-md-12">
				<div class="table-responsive">
					<form role="form" id="templatemo-preferences-form"
						onsubmit="return false;">
						<div class="row">
							<input type="hidden" id="id" value="<?=$deliveryman['id']?>" />
							<div class="col-md-6 margin-bottom-15">
								<label for="firstName" class="control-label">姓名</label> <input
									type="text" class="form-control" id="name" value="<?php echo $deliveryman['name']; ?>">
							</div>
							<div class="col-md-6 margin-bottom-15">
								<label for="lastName" class="control-label">性别</label> <select
									class="form-control margin-bottom-15" id="gender">
									<option value="0" <?php if($deliveryman['gender'] ==0) echo "selected"; ?> >男</option>
									<option value="1" <?php if($deliveryman['gender'] ==1) echo "selected"; ?> >女</option>
								</select>
							</div>
							<div class="col-md-6 margin-bottom-15">
								<label for="firstName" class="control-label">手机号</label> <input
									type="text" class="form-control" id="phone" value="<?php echo $deliveryman['phone']; ?>">
							</div>
							<div class="col-md-6 margin-bottom-15">
								<label for="lastName" class="control-label">类型</label> <select
									class="form-control margin-bottom-15" id="type">
									<option value="0" <?php if($deliveryman['type'] ==0) echo "selected"; ?>>全职</option>
									<option value="1" <?php if($deliveryman['type'] ==1) echo "selected"; ?>>兼职</option>
								</select>
							</div>
							<div class="col-md-6 margin-bottom-15">
								<label for="firstName" class="control-label">支付宝账号</label> <input
									type="text" class="form-control" id="account" value="<?php echo $deliveryman['account']; ?>">
							</div>
						</div>
						<div class="row templatemo-form-buttons">
	                		<div class="col-md-12">
	                 		 <button type="submit" class="btn btn-primary" id="submit_btn">修改</button>
	                		</div>
               			</div>
					</form>
				</div>
			</div>
		</div>
	</div>
</div>
<script>
	$(document).ready(function() {
		$("#submit_btn").click(function() {
			var id = $("#id").val();
			var name = $("#name").val();
			var gender = $("#gender").val();
			var phone = $("#phone").val();
			var type = $("#type").val();
			var account = $("#account").val();
			$.ajax({
				url : '<?php echo site_url('deliveryman/save')?>',
				type : "post",
				async : true,
				data : {
					'id' : id,
					'name' : name,
					'gender' : gender,
					'phone' : phone,
					'type' : type,
					'account' : account
				},
				dataType : "json",
				timeout : "1000",
				error : function() {
					alert("服务加载出错");
				},
				success : function(data) {
					if(data.code)
					{
						alert(data.msg);
					}else{
						alert(data.msg);
					}
					
				}
			});
		});
	}); 
</script>